<template>
	<view class="main">
		<view class="active_tit">
			<view class="tit">
				其他主体
			</view>

		</view>
		<block v-for="(item,index) in stdOffsurEntRelation" :key='index'>
			<!-- 区分关联企业还是关联人 1，自然人，2企业-->
			<block v-if="item.subjectType=='1'">
				<view class="cut">关联人{{index+1}}
					<uni-icons class="clear" type="clear"
						@click='stdDel(stdOffsurEntRelation,item,"stdOffsurEntRelation")'></uni-icons>
				</view>
				<view class="main">
					<view class="active_tit">
						<view class="tit2">
							基本信息
						</view>
					</view>
					<ActiveForm style="width: 100%;" v-if="!item.uuid">
						<view class="active_label">
							<button :disabled='!!item.uuid' @click="openOcr(item)" size="mini" type="primary">身份证识别</button>
						</view>	
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							关联类型：
						</view>
						<view class="active_input">
							<SelectPicker :disabled="!!item.uuid" v-model="item.relType" :options="relTypeOption2" placeholder="请选择" />
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							名称：
						</view>
						<view class="active_input">
							<input :disabled="!!item.uuid" type="text" v-model.trim="item.entName" />
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							身份证号码：
						</view>
						<view class="active_input">
							<input :disabled="!!item.uuid" type="text" @input="cardCheck($event,item,'creditCode')" v-model.trim="item.creditCode" />
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							证件有效期起始日：
						</view>
						<view class="active_input">
							<view v-if="!item.creditCode" >请先输入证件号码</view>
							<picker v-else style="width: 100%;" mode="date" :value="item.startDate"   @change="(o)=>{item.startDate=o.target.value}">
							    <view >{{item.startDate}}</view>
							</picker>
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							证件有效期终止日：
						</view>
						<view class="active_input">
							<view v-if="!item.creditCode">请先输入证件号码</view>
							<picker v-else style="width: 70%;" mode="date" :value="item.endDate"   @change="(o)=>{item.endDate=o.target.value}">
							    <view >{{item.endDate}}</view>
							</picker>
							<button   type="primary" size="mini" @click="()=>{item.endDate='长期'}">长期</button>
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							住所（通讯地址）：
						</view>
						<view class="active_input">
							<!-- <input type="text" v-model="item.opeAdd" /> -->
							<RegionPicker :disabled="!!item.uuid" :value="address(item.opeAdd)" :options="region"
								@change="((o)=>{item.opeAdd=o.value.toString()})" />
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							详细地址：
						</view>
						<view class="active_input">
							<input :disabled="!!item.uuid" type="text" v-model="item.businessDetailAddress" />

						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							婚姻状况：
						</view>
						<view class="active_input">
							<SelectPicker v-model="item.maritalStatus" :options="maritalStatusOption"
								placeholder="请选择" />
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							联系电话：
						</view>
						<view class="active_input">
							<input :disabled="!!item.uuid" type="text" v-model.trim="item.telephone" />

						</view>
					</ActiveForm>
					<view class="active_tit">
						<view class="tit2">
							工作及财务信息
						</view>
					</view>
					<ActiveForm required>
						<view class="active_label">
							工作单位：
						</view>
						<view class="active_input">
							<input type="text" v-model="item.employer" />

						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							职务：
						</view>
						<view class="active_input">
							<input type="text" v-model="item.position" />

						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							单位地址：
						</view>
						<view class="active_input">
							<input type="text" v-model="item.employerAddress" />

						</view>
					</ActiveForm>
					<ActiveForm >
						<view class="active_label">
							年收入（元）：
						</view>
						<view class="active_input">
							<mInput maxlength="16" type="number" v-model="item.incomeYear" />
						</view>
					</ActiveForm>
					<ActiveForm >
						<view class="active_label">
							资产金额（元）：
						</view>
						<view class="active_input">
							<mInput maxlength="16" type="number" v-model="item.endTotalAssets" />
						</view>
					</ActiveForm>

					<ActiveForm >
						<view class="active_label">
							负债金额（元）：
						</view>
						<view class="active_input">
							<mInput maxlength="16" type="number" v-model="item.endTotalLiability" />
						</view>
					</ActiveForm>
					<ActiveForm>
						<view class="active_label">
							备注：
						</view>
						<view class="active_input">
							<input type="text" v-model="item.remark" />

						</view>
					</ActiveForm>

				</view>


			</block>
			<block v-if="item.subjectType=='2'">
				<view class="cut">关联企业{{index+1}}
					<uni-icons class="clear" type="clear"
						@click='stdDel(stdOffsurEntRelation,item,"stdOffsurEntRelation")'></uni-icons>
				</view>
				<view class="main">
					<view class="active_tit">
						<view class="tit2">
							基本信息
						</view>
					</view>
					<ActiveForm style="width: 100%;" v-if="!item.uuid">
						<view class="active_label">
							<button :disabled='!!item.uuid' @click="chooseImg(item)" size="mini" type="primary">证件识别</button>
						</view>	
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							关联类型：
						</view>
						<view class="active_input">
							<SelectPicker :disabled="!!item.uuid" v-model="item.relType" :options="relTypeOption" placeholder="请选择" />
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							企业名称：
						</view>
						<view class="active_input">
							<input :disabled="!!item.uuid" type="text" v-model.trim="item.entName" />
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							统一社会信用代码：
						</view>
						<view class="active_input">
							<input :disabled="!!item.uuid" type="text" @input="cardCheck($event,item,'creditCode')" v-model.trim="item.creditCode" />
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							证件有效期起始日：
						</view>
						<view class="active_input">
							<view v-if="!item.creditCode" >请先输入统一社会信用代码</view>
							<picker v-else style="width: 100%;" mode="date" :value="item.entStartDate"   @change="(o)=>{item.entStartDate=o.target.value}">
							    <view >{{item.entStartDate}}</view>
							</picker>
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							证件有效期终止日：
						</view>
						<view class="active_input">
							<view v-if="!item.creditCode">请先输入统一社会信用代码</view>
							<picker v-else style="width: 70%;" mode="date" :value="item.entEndDate"   @change="(o)=>{item.entEndDate=o.target.value}">
							    <view >{{item.entEndDate}}</view>
							</picker>
							<button   type="primary" size="mini" @click="()=>{item.entEndDate='长期'}">长期</button>
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							法定代表人：
						</view>
						<view class="active_input">
							<input :disabled="!!item.uuid" type="text" v-model.trim="item.frName" />
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							法人身份证号码：
						</view>
						<view class="active_input">
							<input :disabled="!!item.uuid" type="text" v-model.trim="item.legalIdCode" />
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							证件有效期起始日：
						</view>
						<view class="active_input">
							<view v-if="!item.legalIdCode" >请先输入法人身份证号码</view>
							<picker v-else style="width: 100%;" mode="date" :value="item.startDate"   @change="(o)=>{item.startDate=o.target.value}">
							    <view >{{item.startDate}}</view>
							</picker>
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							证件有效期终止日：
						</view>
						<view class="active_input">
							<view v-if="!item.legalIdCode">请先输入法人身份证号码</view>
							<picker v-else style="width: 70%;" mode="date" :value="item.endDate"   @change="(o)=>{item.endDate=o.target.value}">
							    <view >{{item.endDate}}</view>
							</picker>
							<button   type="primary" size="mini" @click="()=>{item.endDate='长期'}">长期</button>
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							法人联系电话：
						</view>
						<view class="active_input">
							<input :disabled="!!item.uuid" type="text" v-model.trim="item.telephone" />
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							主营业务：
						</view>
						<view class="active_input">
							<input type="text" v-model="item.mainBusi" />
						</view>
					</ActiveForm>

					<ActiveForm required>
						<view class="active_label">
							营业地址：
						</view>
						<view class="active_input">
							<!-- <input type="text" v-model="item.opeAdd" /> -->
							<RegionPicker :value="address(item.opeAdd)" :options="region"
								@change="((o)=>{item.opeAdd=o.value.toString()})" />
						</view>
					</ActiveForm>
					<ActiveForm required>
						<view class="active_label">
							详细地址：
						</view>
						<view class="active_input">
							<input type="text" v-model="item.businessDetailAddress" />
						</view>
					</ActiveForm>
					<ActiveForm >
						<view class="active_label">
							备注：
						</view>
						<view class="active_input">
							<input type="text" v-model="item.remark" />

						</view>
					</ActiveForm>
					<view class="active_tit">
						<view class="tit2">
							简要经营及财务数据
						</view>
					</view>
					<ActiveForm >
						<view class="active_label">
							期末总资产（元）：
						</view>
						<view class="active_input">
							<mInput maxlength="16" type="number" v-model="item.endTotalAssets" />
						</view>
					</ActiveForm>
					<ActiveForm >
						<view class="active_label">
							期末总负债（元）：
						</view>
						<view class="active_input">
							<mInput maxlength="16" type="number" v-model="item.endTotalLiability" />
						</view>
					</ActiveForm>
					<ActiveForm v-show="!isPad">
						<view class="active_label">
							期末净资产（元）：
						</view>
						<view class="active_input">
							<mInput maxlength="16" type="number" :disabled="true"
                :value="(item.endTotalAssets - item.endTotalLiability).toFixed(2)"
                @input="item.endNetAssets = $event.target.value"
              />
						</view>
					</ActiveForm>
					<ActiveForm >
						<view class="active_label">
							本年营业收入（元）：
						</view>
						<view class="active_input">
							<mInput maxlength="16" type="number" v-model="item.incomeYear" />
						</view>
					</ActiveForm>
					<ActiveForm >
						<view class="active_label">
							本年营业利润 （元）：
						</view>
						<view class="active_input">
							<mInput maxlength="16" type="number" v-model="item.profitYear" />
						</view>
					</ActiveForm>
					<ActiveForm >
						<view class="active_label">
							本年净利润 （元）：
						</view>
						<view class="active_input">
							<mInput maxlength="16" type="number" v-model="item.netProfitYear" />
						</view>
					</ActiveForm>
					<ActiveForm v-show="!isPad">
						<view class="active_label">
							资产负债率 （%）：
						</view>
						<view class="active_input">
							<mInput :thousand='false' maxlength="16" type="number" :disabled="true"
                      :value="(item.endTotalLiability/item.endTotalAssets).toFixed(2)*100"
                      @input="item.liabilityRatio = $event.target.value"
              />
						</view>
					</ActiveForm>
					<ActiveForm v-show="!isPad">
						<view class="active_label">
							营业利润率 （%）：
						</view>
						<view class="active_input">
							<mInput :thousand='false' maxlength="16" type="number" :disabled="true"
                      :value="(item.profitYear/item.incomeYear).toFixed(2)*100"
                      @input="item.profitRatio = $event.target.value"
              />
						</view>
					</ActiveForm>
					<ActiveForm v-show="!isPad">
						<view class="active_label">
							净利率 （%）：
						</view>
						<view class="active_input">
							<mInput :thousand='false' maxlength="16" type="number" :disabled="true"
                      :value="(item.netProfitYear/item.incomeYear).toFixed(2)*100"
                      @input="item.netProfit = $event.target.value"
              />
						</view>
					</ActiveForm>
				</view>
			</block>
			<view class="btn">
				<button v-if="!item.uuid" type="primary" size="mini" @click="save(item)">保存</button>
				<block v-else>
					<button type="default" size="mini" @click="qcode(item.auth)">其他主体授权</button>
					<button type="primary" :disabled="item.auth.isAuth=='未授权'" size="mini"
						@click="look(item.auth)">查看征信报告</button>
					<button v-if="item.subjectType=='2'" type="primary" :disabled="item.auth.authedTax=='未授权'" size="mini"
						@click="look2(item.auth)">查看税务数据</button>
					<button type="primary" size="mini" @click="refresh(item)">刷新</button>
				</block>
			</view>
		</block>
		<view class="active_tit">
			<view class="" style="display: flex;">
				<view class="add" @click="add">
					添加关联企业
				</view>
				<view class="add" @click="add2">
					添加关联人
				</view>
			</view>
		</view>
		
		<!-- 弹框 -->
		<uni-popup ref="popupQ2" type="dialog" style="width: 70rem;height: 45rem;">
					<uni-popup-dialog @confirm='pclick' title="授权二维码" :showCancel="false" type="info" :duration="2000"
						style="width: 100%;height: 100%;">
						<view class="qcode">
							<text style="font-size: 2.8rem;">请使用手机自带浏览器扫描</text>
							<view class="qcodeCont" >
								<!-- 非企业不展示税务授权二维码 -->
								<view class="cont" v-if="tobeAuthType!=='3'">
									<view style="font-size: 2.8rem;padding-bottom: 2rem;">征信/综合数据查询授权</view>
									<tki-qrcode :size='400' cid="qrcode3" ref="qrcode3" :val="val" :showLoading="true" style="width: 50%;height: 100%;margin:0 auto" />
									<view style="font-size: 2.8rem;padding-top: 2rem;">征信/综合数据查询授权：
									<text v-if="isAuth==='已授权'" style="color: blue;font-weight: bold;">{{isAuth}}</text>
									<text v-else style="color: red;font-weight: bold;">{{isAuth}}</text>
									</view>
								</view>
								<!-- <view class="cont" v-if="tobeAuthType==='3'">
									<view style="font-size: 2.8rem;padding-bottom: 2rem;">第一步：征信/综合数据查询授权</view>
									<tki-qrcode :size='400' cid="qrcode3" ref="qrcode3" :val="val" :showLoading="true" style="width: 100%;height: 100%;" />
								    <view style="font-size: 2.8rem;padding-top: 2rem;">征信/综合数据查询授权：
									<text v-if="isAuth==='已授权'" style="color: blue;font-weight: bold;">{{isAuth}}</text>
									<text v-else style="color: red;font-weight: bold;">{{isAuth}}</text>
									</view>
								</view> -->
								<view class="cont" v-show="tobeAuthType==='3'" >
									<view style="font-size: 2.8rem;padding-bottom: 2rem;">税务数据查询授权</view>
									<tki-qrcode :size='400' cid="qrcode4" ref="qrcode4" :val="val2" :showLoading="true" style="width: 50%;height: 100%;margin:0 auto" />
								    <view style="font-size: 2.8rem;padding-top: 2rem;">税务数据查询授权：
									<text v-if="authedTax==='已授权'" style="color: blue;font-weight: bold;">{{authedTax}}</text>
									<text v-else style="color: red;font-weight: bold;">{{authedTax}}</text>
									</view>
								</view>
							</view>
							
						</view>
					</uni-popup-dialog>
				</uni-popup>
		
		
		
		<uni-popup ref="popups" type="dialog" style="width: 70rem;height: 40rem;">
			<uni-popup-dialog @confirm='zxbgcon' title="征信报告" type="info" :duration="2000"
				style="width: 100%;height: 100%;">
				<scroll-view scroll-y="true" style="height: 70rem;">
					<view class="zx" v-append="zxbg" @appended="appended"></view>
				</scroll-view>
			</uni-popup-dialog>
		</uni-popup>
		<uni-popup ref="popup3" type="dialog" style="width: 40rem;height: 40rem;">
			<uni-popup-dialog @confirm='zxbgcon2' title="税务数据" type="info" :duration="2000"
				style="width: 100%;height: 100%;">
				<scroll-view scroll-y="true" style="height: 70rem;">
					<n-table :tableHeight="200" ref="table1" :nameOpt="{title:'纳税人基本信息'}" colKey='prop' :columns='col' :tableData='tableData'></n-table>
					<n-table ref="table3" :nameOpt="{title:'查询企业增值税申报行为'}" colKey='prop' :columns='col3' :tableData='tableData3'></n-table>
					<n-table ref="table2" :nameOpt="{title:'查询企业所得税申报行为'}" colKey='prop' :columns='col2' :tableData='tableData2'></n-table>
					
				</scroll-view>
			</uni-popup-dialog>
		</uni-popup>
		
		<!-- 证件OCR -->
		<uni-popup ref="imgPopups" type="dialog" style="width: 70rem;height: 40rem;">
			<uni-popup-dialog @confirm='ocrImg2' :before-close="true" @close="ocrClose" title="选择影像" type="info" :duration="2000"
				style="width: 100%;height: 100%;">
				<view style="width: 100rem;height:50rem;display:flex;">
					<view style="display:flex;justify-content: center;flex-direction: column;align-items: center;">
						<button  @click="chooseImg2('1')" size="mini" type="primary">选择身份证正面</button>
						<image style='width: 50rem;height: 25rem;' :src="ocrImgUrl1" mode=""></image>
					</view>
					<view style="display:flex;justify-content: center;flex-direction: column;align-items: center;">
						<button  @click="chooseImg2('2')" size="mini" type="primary">选择身份证反面</button>
					    <image style='width: 50rem;height: 25rem;' :src="ocrImgUrl2" mode=""></image>
					</view>
				</view>
			</uni-popup-dialog>
		</uni-popup>
		
		
	</view>
</template>

<script>
	import chooseImgToBase64 from "@/utils/chooseImgToBase64";
	import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue"
	import uniPopupDialog from "@/components/uni-popup-dialog/uni-popup-dialog.vue";
	import SelectPicker from "../../SelectPicker";
	import RegionPicker from "../../RegionPicker";
	import region from '../areaList.js'
	export default {
		name: 'activeForm',
		data() {
			return {
				ocrImgUrl1:'',
				ocrImgUrl2:'',
				ocrImgData1:'',
				ocrImgData2:'',
				ocrTypes:'',
				ocrItem:{},
				authedTax:'未授权',
				isAuth:'未授权',
				tobeAuthType:'',
				tableData:[],
				col:[],
				tableData2:[],
				col2:[],
				tableData3:[],
				col3:[],
				val: '',
				val2: '',
				zxbg: '',
				region,
				isPad: true,
				province: "",
				city: "",
				county: "",
				index: 1,
				form: {
					corCerttype: '',
					checked: '',
					arr: [{
						name: ''
					}, ]
				},
				stdOffsurEntRelation: [],
				relTypeOption: [],
				relTypeOption2: [],
				maritalStatusOption: [
					{value: "01",
						label: "未婚"
					},
					{
						value: "02",
						label: "已婚"
					},
					{
						value: "03",
						label: "丧偶"
					},
					{
						value: "04",
						label: "离婚"
					},
				]
			}
		},
		components: {
			SelectPicker,
			RegionPicker
		},
		computed: {
			address() {
				return function(val) {
					//debugger
					if (val == '' || val == null) {
				 	return []
					} else {
						let arr = val.split(",")
						return arr
					}
				}
			}
		},
		watch: {
			stdOffsurEntRelation: {
				handler: function(res) {
					//console.warn('组件数据变化', res)
					getApp().globalData.stdOffsurEntRelation = res
				},
				deep: true
			}
		},
		mounted() {
			this.isPad = getApp().globalData.isPad
			//获取返显数据
			setTimeout(() => {
				//数据反显
				//自然人  IND_REL
				//企业  ENT_REL
				this.relTypeOption = getApp().globalData.optType.ENT_REL
				this.relTypeOption2 = getApp().globalData.optType.IND_REL
				 
				if (getApp().globalData.stdOffsurEntRelation !== null) {
					this.stdOffsurEntRelation = getApp().globalData.stdOffsurEntRelation
				}
			}, getApp().globalData.timeout)
		},
		methods: {
			//=====新增ocr============
			openOcr(item){
				this.ocrItem = item
				this.$refs.imgPopups.open()
			},
			chooseImg2(type){
				chooseImgToBase64(
					(base64, base64SourceData, file) => {
						this.ocrTypes = file.type.split('/')
						if(type==='1'){
							this.ocrImgUrl1 = base64
							this.ocrImgData1 = base64SourceData
						}else{
							this.ocrImgUrl2 = base64
							this.ocrImgData2 = base64SourceData
						}
						
					}, 500
							
				);
				
			},
			chooseImg(item) {
			
				chooseImgToBase64(
					(base64, base64SourceData, file) => {
						this.ocrImg(item,base64SourceData,file)
					}, 500
			
				);
			},
			ocrImg(item,base64){
				this.sendRequest({
					url: 'businessLicense/businessLicenseRec',
					method: 'post',
					hideLoading: false,
					data: {
						"imageFile": base64,
					},
					complete: (res) => {
						if (res.code == '200'&&res.data.result==='0') {
							let cont = res.data.ocrResult
							for(let i=0;i<cont.length;i++){
								if(cont[i].fieldName==='统一社会信用代码'){
									item.creditCode = cont[i].fieldValue	
								}else if(cont[i].fieldName==='名称'){
									item.entName = cont[i].fieldValue	
								}else if(cont[i].fieldName==='法定代表人'){
									item.frName = cont[i].fieldValue	
								}
							}
						} else {
							uni.showToast({
								icon: "none",
								title: 'OCR识别失败，请重试',
								duration: 2000
							})
						}
					}
				})
				
			},
			ocrClose(){
				this.ocrImgUrl1 = ''
				this.ocrImgUrl2 = ''
				this.ocrImgData1=''
				this.ocrImgData2=''
				this.$refs.imgPopups.close()
				
			},
			ocrImg2(){
				if(!this.ocrImgData2||!this.ocrImgData1){
					uni.showToast({
						icon: "none",
						title: '请上传完整证件正反面影像',
						duration: 2000
					})
					return false
				}
				
				this.sendRequest({
					url: 'ocr/ocrIdCard',
					method: 'post',
					hideLoading: false,
					data: {
						"backImg": this.ocrImgData2,
						"backImgSuffix":this.ocrTypes[1],	
						"frontImg": this.ocrImgData1,
						"frontImgSuffix":this.ocrTypes[1],
						"reqId": getApp().globalData.stdOffsurBaiscInfo.reqId,
						"businessId": getApp().globalData.stdOffsurBaiscInfo.businessId,
					},
					complete: (res) => {
						if (res.code == '200') {
							this.ocrItem.entName = res.data.ucName
							this.ocrItem.creditCode = res.data.ucNumber
							this.ocrItem.startDate = res.data.dateStart
							this.ocrItem.endDate = res.data.dateEnd
							
							this.ocrClose()
						} else {
							uni.showToast({
								icon: "none",
								title: 'OCR识别失败，请重试',
								duration: 2000
							})
						}
					}
				})
				
			},
			//==================
			zxbgcon() {
				this.$refs.popups.close()
			},
			zxbgcon2() {
				this.$refs.popup3.close()
			},
			//查看二维码
			qcode(item) {
				console.log(item)
				this.tobeAuthType = item.tobeAuthType
				this.authedTax = item.authedTax
				this.isAuth = item.isAuth
				this.val = ''
				this.val2 = ''
				this.val = getApp().globalData.toUrl + '?reqId=' + getApp().globalData.stdOffsurBaiscInfo.reqId +
					'&&tobeId=' + item.id + '&&tobeAuthType=' + item.tobeAuthType +
					'&&customerType=' + item.customerType + '&&entityRoleType=' + item.entityRoleType + '&&customerName=' +
					item.customerName
				this.val2 = getApp().globalData.toUrl + '?reqId=' + getApp().globalData.stdOffsurBaiscInfo.reqId +
					'&&tobeId=' + item.id + '&&offsurRelation=' +item.offsurRelationId + '&&checkPass=2&&subjectFlag=1'  + '&&tobeAuthType=' + item.tobeAuthType	
				this.$refs.popupQ2.open()
				console.warn(this.val)
				setTimeout(() => {
					
					if(this.tobeAuthType==='3'){
						this.$refs.qrcode4._makeCode()
					}else{
						this.$refs.qrcode3._makeCode()
					}
					
				}, 500)
			
			},
			pclick(item) {
				
				if(this.tobeAuthType==='3'){
					this.$refs.qrcode4._clearCode()
				}else{
					this.$refs.qrcode3._clearCode()
				}
				
				this.$refs.popupQ2.close();
			
			},
			look(item){
				// /offsur/query/subjectData
				this.sendRequest({
					url: 'offsur/query/subjectData',
					method: 'post',
					hideLoading: false,
					data: {
						reqID:getApp().globalData.reqId,
						customerSystemId:item.customerSystemId,
						customerType:item.customerType,
						queryType:'01',
						type:'pad'
					},
					complete: (res2) => {
						console.log(res2)
						if (res2.code == '200') {
							if (!res2.data) {
								uni.showToast({
									icon: "none",
									title: '获取失败，请重试',
									duration: 2000
								})
							} else {
								this.$refs.popups.open()
								let html = res2.data.credit.htmlMessage
								this.zxbg = html
							}
			
						} else {
							uni.showToast({
								icon: "none",
								title: res2.message,
								duration: 2000
							})
						}
					}
				})
				
			},
			look2(item){
				// /offsur/query/subjectData
				this.sendRequest({
					url: 'offsur/query/subjectData',
					method: 'post',
					hideLoading: false,
					data: {
						reqID:getApp().globalData.reqId,
						customerSystemId:item.customerSystemId,
						customerType:item.customerType,
						queryType:'02',
						type:'pad'
					},
					complete: (res2) => {
						console.log(res2)
						if (res2.code == '200') {
							if (!res2.data) {
								uni.showToast({
									icon: "none",
									title: '获取失败，请重试',
									duration: 2000
								})
							} else {
								// 表头处理
								let col = res2.data.basic.col
								for(let i=0;i<col.length;i++){
									 col[i].width = 200
								}
								this.col =col
								this.tableData =res2.data.basic.data
								let col2 = res2.data.income.col
								// for(let i=0;i<col2.length;i++){
								// 	 col2[i].width = 120
								// }
								this.col2 =col2
								this.tableData2 =res2.data.income.data
								let col3 = res2.data.vat.col
								this.col3 =col3
								this.tableData3 =res2.data.vat.data
								
								this.$refs.popup3.open()
								
							}
				
				
						} else {
							uni.showToast({
								icon: "none",
								title: res2.message,
								duration: 2000
							})
						}
					}
				})
				
			},

			cardCheck(e, item, name) {
				setTimeout(() => {
					item[name] = e.target.value.replace(/[^\a-\z\A-\Z0-9]/g, '')
				}, 50)
			},
			add() {
				this.stdOffsurEntRelation.push({
					startDate:"",
					endDate:"",
					entStartDate:"",
					entEndDate:"",
					auth: {
						isAuth: '未授权'
					},
					subjectType: '2',
					"actualController": "",
					"customerId": "",
					"customerSystemId": "",
					"endNetAssets": '',
					"endTotalAssets": '',
					"endTotalLiability": '',
					"entName": "",
					"entityRoleType": "",
					"frName": "",
					"getDatTime": "",
					"imageUrl": "",
					"incomeYear": '',
					"liabilityRatio": '',
					"mainBusi": "",
					"netProfit": '',
					"netProfitYear": '',
					"opeAdd": "",
					"profitRatio": '',
					"profitYear": '',
					"regAdd": "",
					"regTime": "",
					"relType": "",
					"reqId": "",
					"sourceSystem": "",
					"xh": "",
					uuid:'',
					remark: '',
					businessDetailAddress: ''
				})
			},
			add2() {
				this.stdOffsurEntRelation.push({
					startDate:"",
					endDate:"",
					entStartDate:"",
					entEndDate:"",
					auth: {
						isAuth: '未授权'
					},
					subjectType: '1',
					"actualController": "",
					"customerId": "",
					"customerSystemId": "",
					"endNetAssets": '',
					"endTotalAssets": '',
					"endTotalLiability": '',
					"entName": "",
					"entityRoleType": "",
					"frName": "",
					"getDatTime": "",
					"imageUrl": "",
					"incomeYear": '',
					"liabilityRatio": '',
					"mainBusi": "",
					"netProfit": '',
					"netProfitYear": '',
					"opeAdd": "",
					"profitRatio": '',
					"profitYear": '',
					"regAdd": "",
					"regTime": "",
					"relType": "",
					"reqId": "",
					"sourceSystem": "",
					"xh": "",
					uuid:'',
					remark: '',
					businessDetailAddress: ''
				})
			},
			save(item) { //保存个人
				// 202206反洗钱需求校验
				let nowDate= new Date().getTime()
				if(!item.endDate||!item.startDate){
					uni.showToast({
						title: '其他主体客户证件有效期不能为空',
						icon: "none",
						duration: 2000
					})
					return false
				}
				
				
				let endDate = new Date(item.endDate).getTime()
				let startDate = new Date(item.startDate).getTime() 
				if(item.endDate!="长期"){	
						if(nowDate>endDate){
							uni.showToast({
								title: '其他主体客户证件已过期，请核实并更新证件后提交！',
								icon: "none",
								duration: 2000
							})
							return false
						}
						if(nowDate<startDate){
							uni.showToast({
								title: '其他主体客户证件起始时间大于当前时间，请核实并更新证件后提交！',
								icon: "none",
								duration: 2000
							})
							return false
						}
				
				}else{
					if(nowDate<startDate){
						uni.showToast({
							title: '其他主体客户证件起始时间大于当前时间，请核实并更新证件后提交！',
							icon: "none",
							duration: 2000
						})
						return false
					}
					
				}

				if (item.subjectType === '1') {
					if (!item.relType || !item.entName || !item.creditCode || !item.opeAdd || !item.businessDetailAddress || !
						item.maritalStatus || !item.telephone || !item.employer || !item.position || !item.employerAddress ||
						item.incomeYear==='' || item.endTotalAssets==='' || item.endTotalLiability===''
					) {
						uni.showToast({
							title: '请补全主体：' + item.entName + '必填项！',
							icon: "none",
							duration: 2000
						})
						return false
					}

				} else {
					if (!item.relType || !item.entName || !item.creditCode||!item.frName||!item.legalIdCode || !item.telephone || !item.mainBusi || !item.opeAdd || !item.businessDetailAddress || item.endTotalAssets==='' ||
						item.endTotalLiability==='' || item.incomeYear==='' || item.profitYear===''|| item.netProfitYear===''
					) {
						uni.showToast({
							title: '请补全主体：' + item.entName + '必填项！',
							icon: "none",
							duration: 2000
						})
						return false
					}
					
					if(!item.entEndDate||!item.entStartDate){
						uni.showToast({
							title: '其他主体客户证件有效期不能为空',
							icon: "none",
							duration: 2000
						})
						return false
					}
					
					let entEndDate = new Date(item.entEndDate).getTime()
					let entStartDate = new Date(item.entStartDate).getTime()
					if(item.entEndDate!="长期"){									
							if(nowDate>entEndDate){
								uni.showToast({
									title: '其他主体客户证件已过期，请核实并更新证件后提交！',
									icon: "none",
									duration: 2000
								})
								return false
							}
							if(nowDate<entStartDate){
								uni.showToast({
									title: '其他主体客户证件有效期有误！',
									icon: "none",
									duration: 2000
								})
								return false
							}
					
					}else{
						if(nowDate<entStartDate){
							uni.showToast({
								title: '其他主体客户证件有效期有误！',
								icon: "none",
								duration: 2000
							})
							return false
						}
					}

				}
				
				
				

				

				this.sendRequest({
					url: '/offsur/save_other_subject',
					method: 'post',
					hideLoading: false,
					data: {
						stdOffsurEntRelation: item,
						stdOffsurBaiscInfo: getApp().globalData.stdOffsurBaiscInfo,
						stdOffsursDelete: getApp().globalData.stdOffsursDelete,
					},
					complete: (res) => {
						console.log(res)
						if (res.code == '200') {
							item.uuid = res.data.offsurRelationId
							item.auth = res.data
							item.authFlag = '1'

							this.$emit('saveCache', true)
						} else {
							uni.showToast({
								icon: "none",
								title: res.message,
								duration: 2000
							})
						}
					}
				})

			},
			refresh(item){
				
				this.sendRequest({
					url: '/offsur/query_guarantee',
					method: 'post',
					hideLoading: true,
					data: {
						"reqId":getApp().globalData.stdOffsurBaiscInfo.reqId,
						 "offsurRelationId":item.auth.offsurRelationId
					},
					complete: (res) => {
						console.log(res)
						if (res.code == '200') {
							item.auth = res.data
						} else {
							uni.showToast({
								icon: "none",
								title: res.message,
								duration: 2000
							})
						}
					}
				})
			}

		}
	}
</script>

<style lang="scss">
	.zx {
		width: 200rem;
		height: 100rem;
	}
	.qcode {
		width: 120rem;
		height: 75rem;
		text-align: center;
	
		uni-image {
			width: 100%;
			height: 100%;
		}
	
		image {
			width: 100%;
			height: 100%;
		}
		.qcodeCont{
			display:flex;
			height:60rem;
			.cont{
				padding:2rem;
				width:100%;
				height:60rem;
			}
		}
	}


</style>
